<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>Document</title>

</head>
<body>
    <div id="app">
        {{msg}}<br/>
        <input type="button" v-on:click="test1" value="button1"/><br/>
        <button @click="test2">button2</button><br/>
        <button @click="test3('zs',12)">button3</button><br/>
    </div>
   <script>
      
       var vue = new  Vue({
           el:"#app",
           data:{
            msg:'msg'
              
           },
          methods:{
             test1:function(){
                 //方法可以访问data的数据，使用this.data中的变量
                 //方法中的this就Vue对象
                 console.log(this);
                //  alert("test1"+this.msg);
                 this.msg+="aaa";
                //  this.test2();
             },
             test2(){
                 alert("test2");
             },
             test3(name,age){
                 //有参数
                 alert(name+'---'+age);
             }
          }
       })
   </script>
</body>
</html>